import threading
from concurrent.futures import ThreadPoolExecutor, as_completed

lock = threading.Lock()

def run1(i):
    # 抓取的页面url
    with lock:
        print("run1", i)
        return i

if __name__ == '__main__':
    pool = ThreadPoolExecutor(5) #线程并发的属性
    tasks = [pool.submit(run1, i) for i in range(1,5)]

    for f in as_completed(tasks):
        print(f.result())

    pool.shutdown()
    print(tasks)
    print("over")